package com.sunrise.visual.frame.common
{
	public class RadarUtil
	{
		public var config:Object;
		public var data:Array;
		
		public function RadarUtil(data:Array,config:Object)
		{
			this.data = data;
			this.config = config;
		}
		
		private function getXML():XML{
			var xml:XML = <anychart>
			<margin all="0"/>
			  <charts>
			    <chart plot_type="Radar">
			      <chart_settings>
			        <title enabled="false"/>
					<chart_background enabled="false">
				      <inside_margin left="0" top="0" right="0" bottom="0"/>
					</chart_background>
					<data_plot_background enabled="false"/>
			        <axes>
			          <y_axis>
						<scale maximum="100" minimum={this.config.minimum||"auto"} maximum_offset={this.config.maximumOffset||"0.1"}/>
						<major_grid enabled="true">
							<line color="green"></line>
						</major_grid>
						<line enabled="false"/>
			            <labels enabled="false" />
			            <major_tickmark enabled="false" />
			          </y_axis>
						<x_axis>
						<labels><font family="Microsoft Yahei" color="white" bold="false" size="8"></font></labels>
						<line color="green"/>
						<major_tickmark enabled="false"/>
						<title enabled="false"/>
						</x_axis>
			        </axes>
			      </chart_settings>
			      <data_plot_settings>
					<line_series>
					<tooltip_settings enabled="True">
<font family="Microsoft Yahei" bold="false" size="12"/>
					<format>{"{%Name}:{%YValue}{numDecimals:2}"}</format>
					</tooltip_settings>
					</line_series>
					<radar drawing_style="Circle">
					  <background>
						<fill type="Solid" color="#222222"/>
					  </background>
					</radar>
				  </data_plot_settings>
				  <data>
				  </data>
				</chart>
			  </charts>
			</anychart>;
			return xml;
		}
		
		public function parseXML():XML {
			var wdbm:String=this.config.wdbm;
			var zbbm:Array=this.config.zbbm;
			var zbmc:Array=this.config.zbmc;
			var xmlStr:String="";
			//xml.charts[0].chart[0].data[0]="";
			var xml:XML = getXML();
			var seriesColor:Array=['#00DFF3','#95A600'];
			for(var i:int=0;i<zbbm.length;i++){
				xmlStr='<series name="'+zbmc[i]+'">'; 
				for(var j:int=0;j<this.data.length;j++){
					xmlStr+='<point name="'+this.data[j][wdbm]+'" y="'+this.data[j][zbbm[i]]+'"/>';
				}
				xmlStr+='</series>';
				xml.charts[0].chart[0].data[0].appendChild(new XML(xmlStr));
			}
			return xml;
		}
	}
}